<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./node_modules/axios/dist/axios.min.js"></script>
    <style>
      body {
        margin: 0;
        padding: 30px;
      }
    </style>
  </head>
  <body>
    <h3>添加用户</h3>
    用户名：<input type="text" id="username" /> <br />
    密码：<input type="text" id="password" /> <br />
    <button>提交</button>

    <script>
      // 获取按钮添加点击事件
      document.querySelector("button").addEventListener("click", function () {
        //获取用户名和密码
        const username = document.querySelector("#username").value
        const password = document.querySelector("#password").value

        //发送post请求
        axios({
          method: "POST",
          url: "http://localhost:3000/users/",
          data: { username, password },
        }).then((res) => {
        //  跳转首页
        location.href = './index.html'
        })
      })
    </script>
  </body>
</html>
